/**
 * 
 */
package io.dora.registry;

import io.dora.conf.ServiceURL;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


/**
 * 服务注册表
 *
 * @author zhaohongbo
 *
 */
public abstract class AbstractRegistry implements RegistryIndex {

	/** 服务KEY与服务IP map */
	protected Map<String, String> serviceMap = new ConcurrentHashMap<String, String>();
	
	protected ExecutorService pool = Executors.newFixedThreadPool(5);

	@Override
	public void unregister(ServiceURL serviceURL) {
		serviceMap.remove(serviceURL.getPath());
	}

	@Override
	public String get(String serviceKey) {
		return serviceMap.get(serviceKey);
	}

	/**
	 * 发现服务
	 * 
	 * @param serviceKey
	 */
	@Override
	public abstract void lookup(String serviceKey);
	
	/**
	 * 服务消费端服务订阅
	 * 
	 * @param serviceKey
	 */
	@Override
	public abstract void subscribe(String serviceKey);


}
